package com.tinyspot.concrete.starter.business;

import com.tinyspot.concrete.starter.business.model.BatchOrderContext;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @author Tinyspot
 * @date 2023-01-07 22:49
 */
@Component
public class BatchCommonBizProcessor implements BizProcessor<BatchOrderContext, List<Integer>> {
    private List<IProcessor> processorList;

    @Override
    public List<Integer> execute(BatchOrderContext context) {
        if (CollectionUtils.isEmpty(processorList)) {
            return null;
        }

        for (IProcessor processor : processorList) {
            System.out.println(processor.getClass() + " execute...");
            processor.execute(context);
        }

        return Arrays.asList(111, 222);
    }

    public void setProcessorList(List<IProcessor> processorList) {
        this.processorList = processorList;
    }

}
